<?php
/**
 * Created by PhpStorm.
 * User: cape
 * Date: 2017/11/14
 * Time: 7:37
 */

/**
 * @param $rows
 * @param $cols
 * @return string
 */
function createTable($rows, $cols)
{
    $table = "<table border='1' cellpadding='0' cellspacing='0' width='80%'>";
    for ($i = 1; $i <= $rows; $i++) {
        $table .= "<tr>";
        for ($j = 1; $j <= $cols; $j++) {
            $table .= "<td align='center'>x</td>";
        }
        $table .= "</tr>";
    }

    $table .= "</table>";

    return $table;

}


echo createTable(3, 4);
echo '<br/>';
echo createTable(5, 10);

function createTable2($rows= 3,$cols=5,$bgColor='red', $content='x'){

    $table = "<table border='1' width='80%' bgcolor='{$bgColor}' cellspacing='0' cellpadding='0'>";
    for ($i = 1; $i <= $rows; $i++) {
        $table .= "<tr>";
        for ($j = 1; $j <= $cols; $j++) {
            $table .= "<td align='center'>{$content}</td>";
        }
        $table .= "</tr>";
    }

    $table .= "</table>";

    return $table;
}


echo createTable2();
echo '<br/>';
echo createTable2(6,3);
echo '<br/>';
echo createTable2(3,5,'pink');



















